//
//  UILabel+Category.m
//  VICategory
//
//  Created by lan's Mac on 2022/8/26.
//

#import "UILabel+Category.h"

@implementation UILabel (Category)

+ (CGFloat)getLabelHeightWithText:(NSString *)text
                            width:(CGFloat)width
                             font:(CGFloat)font {
    CGRect rect = [text boundingRectWithSize:CGSizeMake(width, MAXFLOAT)
                                     options:NSStringDrawingUsesLineFragmentOrigin
                                  attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]}
                                     context:nil];
    return rect.size.height;
}


+ (CGFloat)getLabelWidthWithText:(NSString *)text
                          height:(CGFloat)height
                            font:(CGFloat)font {
    CGRect rect = [text boundingRectWithSize:CGSizeMake(MAXFLOAT, height)
                                     options:NSStringDrawingUsesLineFragmentOrigin
                                  attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]}
                                     context:nil];
    return rect.size.width;
}

@end
